import 'package:flutter/material.dart';

class KeepAliveWrapper extends StatefulWidget {
  const KeepAliveWrapper(
    this.child, {
    super.key,
    this.keepAlive = true,
  });
  final Widget child;
  final bool keepAlive;
  @override
  State<KeepAliveWrapper> createState() {
    // TODO: implement createState
    return _KeepAliveWrapperState();
  }
}

class _KeepAliveWrapperState extends State<KeepAliveWrapper>
    with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    super.build(context);
    // TODO: implement build
    return widget.child;
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => widget.keepAlive;

  // @override
  // void didUpdateWidget(covariant KeepAliveWrapper oldWidget) {
  //   // TODO: implement didUpdateWidget
  //   if (oldWidget.keepAlive != widget.keepAlive) {
  //     updateKeepAlive();
  //   }
  //   super.didUpdateWidget(oldWidget);
  // }
}
